package C07.List01;
import java.util.ArrayList;
import java.util.Scanner;
public class ArrayListUse03 {
    public static void main(String[] args) {

        ArrayList<String> strings = new ArrayList<>();

        strings.add("苹果");
        strings.add("香蕉");
        strings.add("橘子");
        strings.add("菜");
        strings.add("菜");

        System.out.println(strings);
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入需要修改的水果名称:");
        String fruitName = scanner.next();
        System.out.println(fruitName);
        int index = strings.indexOf(fruitName);
        System.out.println("当前" + fruitName + "下标=" + index);
        strings.set(index,"哈密瓜");
        System.out.println(strings);

        System.out.println("请输入需要删除的水果名称:");
        String fruitNameByDelete = scanner.next();
        strings.remove(fruitNameByDelete);
        System.out.println(strings);

    }
}